package club.zhcs.captrue.utils;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import club.zhcs.capture.vo.Consts;
import club.zhcs.capture.vo.MenuNode;
import org.apache.velocity.tools.config.DefaultKey;
import org.apache.velocity.tools.config.InvalidScope;
import org.nutz.mvc.Mvcs;

@DefaultKey("M")
@InvalidScope({ "application" })
public class MenuUtils {

	public static List<MenuNode> getMenu() {
		List<MenuNode> nodes = (List<MenuNode>) Mvcs.getReq().getSession().getAttribute(Consts.SessionKeys.SESSION_MENU_KEY);
		Collections.sort(nodes, new Comparator<MenuNode>()// 来个排排坐
				{
					@Override
					public int compare(MenuNode o1, MenuNode o2) {
						return o1.getGroup().getIndex() - o2.getGroup().getIndex();
					}
				});
		return nodes;
	}

}
